﻿@page "/navbars"

<h1>Navbars</h1>

<div class="docs-example">
    <BSNavbar IsExpand="true" IsDark="false" Color="Color.Light">
        <BSNavbarBrand Href="javascript:void(0);">Navbar</BSNavbarBrand>
        <BSNavbarToggler @onclick="onclick" />
        <BSCollapse @ref="NavbarCollapse" IsNavbar="true" IsOpenChanged="OpenChanged">
            <BSNav IsList="true" Class="mr-auto" IsNavbar="true">
                <BSNavItem>
                    <BSNavLink IsActive="true" Href="javascript:void(0);">Home</BSNavLink>
                </BSNavItem>
                <BSNavItem>
                    <BSNavLink Href="javascript:void(0);">Link</BSNavLink>
                </BSNavItem>
                <BSNavItem>
                    <BSNavLink IsDisabled="true" Href="javascript:void(0);">Disabled</BSNavLink>
                </BSNavItem>
                <BSNavItem IsDropdown="true">
                    <BSDropdownToggle Color="Color.Light">Dropdown link</BSDropdownToggle>
                    <BSDropdownMenu>
                        <BSDropdownItem Href="javascript:void(0);">Action</BSDropdownItem>
                        <BSDropdownItem Href="javascript:void(0);">Another Action</BSDropdownItem>
                        <BSDropdownItem IsDivider="true" />
                        <BSDropdownItem Href="javascript:void(0);">Yet Another Action</BSDropdownItem>
                    </BSDropdownMenu>
                </BSNavItem>
                <BSNavItem IsDropdown="true" @bind-IsOpen="@UserControlledIsOpen" CloseOnFocusout="false">
                    <BSDropdownToggle @onclick="UserControlledClick" Color="Color.Light">User Controlled</BSDropdownToggle>
                    <BSDropdownMenu @bind-IsOpen="@UserControlledIsOpen">
                        <BSDropdownItem Href="javascript:void(0);">Action</BSDropdownItem>
                        <BSDropdownItem Href="javascript:void(0);">Another Action</BSDropdownItem>
                        <BSDropdownItem IsDivider="true" />
                        <BSDropdownItem Href="javascript:void(0);">Yet Another Action</BSDropdownItem>
                    </BSDropdownMenu>
                </BSNavItem>
            </BSNav>
            <BSForm IsInline="true" Class="my-2 my-lg-0" Model="@formsModel">
                <BSInput InputType="InputType.Search" PlaceHolder="Search" Class="mr-sm-2" @bind-Value="formsModel.Blank" />
                <BSButton IsOutline="true" Color="Color.Success" ButtonType="ButtonType.Submit" Class="my-2 my-sm-0">Search</BSButton>
            </BSForm>
        </BSCollapse>
    </BSNavbar>
</div>
<PrettyCode CodeFile="_content/SampleCore/snippets/navbars/navbars1.html" />

@code {
    private BSCollapse NavbarCollapse;
    private FormsModel formsModel = new FormsModel();
    bool UserControlledIsOpen { get; set; } = true;
    void onclick(MouseEventArgs e)
    {
        NavbarCollapse.Toggle();
        Console.WriteLine("Navbar State->" + NavbarCollapse.IsOpen.ToString());
    }
    void OpenChanged(bool e)
    {
        Console.WriteLine("OpenChanged->" + e.ToString());
    }

    void UserControlledClick(MouseEventArgs e)
    {
        UserControlledIsOpen = !UserControlledIsOpen;
        StateHasChanged();

    }

    public class FormsModel
    {

        public string Blank { get; set; }
    }
}